package com.example.testspringes.modul;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.chrono.ChronoLocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: //TODO
 * @ProjectName: testspringes
 * @Package: com.example.testspringes.modul
 * @Author: FX
 * @CreateDate: 2019/1/18 15:28
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */
public class Test {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        LocalDate birthday = LocalDate.of(2019,3 , 20);
        System.out.println(birthday);
        long between = ChronoUnit.DAYS.between(birthday, now);
        System.out.println(between);
        LocalDateTime plus = now.plus(1, ChronoUnit.MINUTES);
        System.out.println(plus);
        List<Person> collection = new ArrayList();
        collection.add(new Person("张三", 22, "男","1"));
        collection.add(new Person("李四", 19, "女","1"));
        collection.add(new Person("王五", 34, "男","1"));
        collection.add(new Person("赵六", 30, "男","1"));
        collection.add(new Person("田七", 25, "女","1"));
        List<Person> people = collection.stream().filter(c -> c.getGender().equals("男")).collect(Collectors.toList());
        duArr();
        String a="hello";
        Singleton instance = Singleton.getInstance();
        Singleton instance1 = Singleton.getInstance();
        System.out.println(instance==instance1);
        Singleton2 instance2 = Singleton2.INSTANCE;
        Singleton2 instance3 = Singleton2.INSTANCE;
        System.out.println(instance2==instance3);
        System.out.println("========");
        String format = String.format("afsasfasf'%s'fasf", "12");
        System.out.println(format);
        String format1 = String.format("%.2f", 67.876);
        System.out.println(format1);
    }

    private static int f(int n){
        if(1==n){
            return 1;
        }else{
            return n*f(n-1);
        }
    }

    private static void duArr() {
        int[] c={1,2,2,3,4,5,6,5};
        boolean flag=false;
        List<Integer> list = new ArrayList<>();
        for(int i=0,n=c.length;i<n;i++){
            flag=false;
            for(int j=i+1;j<c.length;j++){
                if(c[i]==c[j]){
                    flag=true;
                    break;
                }
            }
            if(!flag){
                list.add(c[i]);
            }
        }
        System.out.println(list);
        int[] ints = Arrays.stream(c).distinct().toArray();
        System.out.println(Arrays.toString(ints));
    }



}
